package org.example.decorator;

/**
 * @author
 * @description 装饰者
 */
public class Decorator extends Drink{

    //组合+继承 构成装饰者
    private Drink drink;

    public Decorator(Drink drink) { //组合
        this.drink = drink;
    }

    /**
     * @return
     */
    @Override
    public float cost() {
        //自己价格
        return super.getPrice()+drink.cost();
    }

    /**
     * @return
     */
    @Override
    public String getDescription() {
        //输出 父类描述+父类价格+被装饰者的信息
        return super.getDescription()+"-----"+super.getPrice()+" && "+drink.getDescription();
    }
}
